#include<iostream>
int cmp(const void* a,const void* b)
{
    return *((int*)((int*)a)[0])<*((int*)((int*)b)[0]);
}

char ** sortPeople(char ** names, int namesSize, int* heights, int heightsSize, int* returnSize){
    int**ret=(int**)malloc(sizeof(int*)*namesSize);
    //int ret[namesSize][2];
    for(int i=0;i<namesSize;i++)
    {
        ret[i]=(int*)malloc(sizeof(int)*2);
        ret[i][0]=heights[i];
        ret[i][1]=i;
    }
    qsort(ret,namesSize,sizeof(int*),cmp);
    char** res=(char**)malloc(sizeof(char*)*namesSize);
    for(int i=0;i<namesSize;i++)
    {
        res[i]=(char*)malloc(sizeof(char)*21);
        strcpy(res[i],names[ret[i][1]]);
    }
    *returnSize=namesSize;
    for(int i=0;i<heightsSize;i++)
    {
        free(ret[i]);
        ret[i]=NULL;
    }
    free(ret);
    ret=NULL;
    return res;
}
